

/*------------------------------------------------------------------------------

	T.7: Effect of SNED on teacher outcomes, teacher-level analysis
							
------------------------------------------------------------------------------*/

global replica_dir=	"<add path to your working directory>"
global data_dir=	"$replica_dir/data"
global output_dir=	"$replica_dir/output"

use "$data_dir/tlvl_fin.dta", clear  


global depvars "horas_contrato  tea_classhrs" 
global indepvars "municip_tm1 rural_rbd_tm1 gender_tm1 tit_educ_tm1 permanent_tm1 tea_admin_tm1 multsch_tm1 i.sned_yr i.hg"


eststo clear

				
* ALL
 				
 				 
foreach yvar of global depvars{
	
eststo: reg `yvar'_tp1 `yvar'_tm1   treat25 st_ind25 st_ind25_sq inter25 inter25_sq  ${indepvars} if abs(st_ind25) <= 1.5, vce(cluster rbd)
eststo: reg `yvar'_tp1 `yvar'_tm1   treat10 st_ind10 st_ind10_sq inter10 inter10_sq  ${indepvars} if abs(st_ind10) <= 1.5, vce(cluster rbd)

}		



* Private voucher 
 
 foreach yvar of global depvars{
	
eststo: reg `yvar'_tp1 `yvar'_tm1   treat25 st_ind25 st_ind25_sq inter25 inter25_sq  ${indepvars} if abs(st_ind25) <= 1.5 & municip==0, vce(cluster rbd)
eststo: reg `yvar'_tp1 `yvar'_tm1   treat10 st_ind10 st_ind10_sq inter10 inter10_sq  ${indepvars} if abs(st_ind10) <= 1.5 & municip==0, vce(cluster rbd)

}		
 
 
 
* Municipal

  				 
foreach yvar of global depvars{
	
eststo: reg `yvar'_tp1 `yvar'_tm1   treat25 st_ind25 st_ind25_sq inter25 inter25_sq  ${indepvars} if abs(st_ind25) <= 1.5 & municip==1, vce(cluster rbd)
eststo: reg `yvar'_tp1 `yvar'_tm1   treat10 st_ind10 st_ind10_sq inter10 inter10_sq  ${indepvars} if abs(st_ind10) <= 1.5 & municip==1, vce(cluster rbd)

}


	

rwolf2 ///
	(reg horas_contrato_tp1  		treat25 st_ind25 st_ind25_sq inter25 inter25_sq  horas_contrato_tm1 ${indepvars} if abs(st_ind25) <= 1.5 , vce(cluster rbd)) ///
	(reg horas_contrato_tp1  		treat10 st_ind10 st_ind10_sq inter10 inter10_sq  horas_contrato_tm1 ${indepvars} if abs(st_ind10) <= 1.5 , vce(cluster rbd)) /// 
	(reg tea_classhrs_tp1 	    	treat25 st_ind25 st_ind25_sq inter25 inter25_sq  tea_classhrs_tm1   ${indepvars} if abs(st_ind25) <= 1.5 , vce(cluster rbd)) ///
	(reg tea_classhrs_tp1      		treat10 st_ind10 st_ind10_sq inter10 inter10_sq  tea_classhrs_tm1   ${indepvars} if abs(st_ind10) <= 1.5 , vce(cluster rbd)) /// 
	(reg horas_contrato_tp1  		treat25 st_ind25 st_ind25_sq inter25 inter25_sq  horas_contrato_tm1 ${indepvars} if abs(st_ind25) <= 1.5  & municip==0, vce(cluster rbd)) ///
	(reg horas_contrato_tp1  		treat10 st_ind10 st_ind10_sq inter10 inter10_sq  horas_contrato_tm1 ${indepvars} if abs(st_ind10) <= 1.5  & municip==0, vce(cluster rbd)) /// 
	(reg tea_classhrs_tp1 	    	treat25 st_ind25 st_ind25_sq inter25 inter25_sq  tea_classhrs_tm1   ${indepvars} if abs(st_ind25) <= 1.5  & municip==0, vce(cluster rbd)) ///
	(reg tea_classhrs_tp1      		treat10 st_ind10 st_ind10_sq inter10 inter10_sq  tea_classhrs_tm1   ${indepvars} if abs(st_ind10) <= 1.5  & municip==0, vce(cluster rbd)) /// 
	(reg horas_contrato_tp1  		treat25 st_ind25 st_ind25_sq inter25 inter25_sq  horas_contrato_tm1 ${indepvars} if abs(st_ind25) <= 1.5  & municip==1, vce(cluster rbd)) ///
	(reg horas_contrato_tp1  		treat10 st_ind10 st_ind10_sq inter10 inter10_sq  horas_contrato_tm1 ${indepvars} if abs(st_ind10) <= 1.5  & municip==1, vce(cluster rbd)) /// 
	(reg tea_classhrs_tp1 	    	treat25 st_ind25 st_ind25_sq inter25 inter25_sq  tea_classhrs_tm1   ${indepvars} if abs(st_ind25) <= 1.5  & municip==1, vce(cluster rbd)) ///
	(reg tea_classhrs_tp1      		treat10 st_ind10 st_ind10_sq inter10 inter10_sq  tea_classhrs_tm1   ${indepvars} if abs(st_ind10) <= 1.5  & municip==1, vce(cluster rbd)) /// 
	, ///
	indepvars(  treat25, treat10,  /// 
				treat25, treat10,  ///
				treat25, treat10,  ///
				treat25, treat10,  ///
				treat25, treat10,  ///
				treat25, treat10  /// 
				) seed(12011303)  cluster(rbd) strata(sned_yr) idcluster(newclusterid) usevalid reps(500) //holm
		
matrix RW=e(RW)		

matrix list RW

foreach v of numlist 1(1)12{ // each variable is a row in RW

scalar rw_pv=RW[`v',3]
scalar h_pv =RW[`v',4]
estadd scalar rw_pv : est`v'
estadd scalar h_pv :  est`v' 

}
				
				
				
local sample="all"
esttab est1 est2 est3 est4  using "$output_dir/post_t_main_`sample'.tex", tex nolines fragment label replace  collabels(none) nomtitles nonumbers star(* 0.10 ** 0.05 *** 0.01) ///
cells(b(star fmt(3)) se(par(( )) fmt(3)) ) ///
keep(treat25 treat10) ///
stats(N r2  rw_pv , fmt(0 3 3 3)  ///
labels(`"Observations"' `"R-squared"' `"Romano-Wolf p-value"' ))


local sample="pv"
esttab est5 est6 est7 est8 using "$output_dir/post_t_main_`sample'.tex", tex nolines fragment label replace  collabels(none) nomtitles nonumbers star(* 0.10 ** 0.05 *** 0.01) ///
cells(b(star fmt(3)) se(par(( )) fmt(3)) ) ///
keep(treat25 treat10) ///
stats(N r2  rw_pv , fmt(0 3 3 3)  ///
labels(`"Observations"' `"R-squared"' `"Romano-Wolf p-value"' ))


local sample="mv"
esttab est9 est10 est11 est12 using "$output_dir/post_t_main_`sample'.tex", tex nolines fragment label replace  collabels(none) nomtitles nonumbers star(* 0.10 ** 0.05 *** 0.01) ///
cells(b(star fmt(3)) se(par(( )) fmt(3)) ) ///
keep(treat25 treat10) ///
stats(N r2  rw_pv , fmt(0 3 3 3)  ///
labels(`"Observations"' `"R-squared"' `"Romano-Wolf p-value"' ))


 

				
				
				
				
				
				
				
				
				